The possible impact of weather on crimes in Amsterdam#
Show code cell source
import pandas as pd
from pandas import Timedelta
import numpy as np
import plotly.express as px
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from IPython.display import display, Markdown
import plotly.io as pio
pio.renderers.default = "notebook"
import plotly.graph_objects as go
from scipy import stats
df = pd.read_csv("merged_weather_misdrijven_monthly_v3.csv")
People have long studied both weather and human behavior. A key question at their intersection is whether weather influences crime.
Some researchers think so: for instance, Anderson (2001) found that high temperatures may increase aggression. In this project, we examine whether weather factors like heat or rain are linked to crime rates in Amsterdam.
We use daily weather data from Schiphol Airport (KNMI, 2025) and monthly crime data from Statistics Netherlands (CBS, 2025). This allows us to explore both seasonal patterns in serious crimes and specific links, such as between warmer days and bike theft.
Using data visualizations, we assess whether crime is weather-dependent or largely unaffected by it.
Perspective 2: Serious crimes are not affected by bad weather#
An alternative perspective shows that, although specific categories of crime may be affected by warm weather conditions, serious crimes show no correlation with weather at all. In this section, we explore how rainfall might relate to burglary, and whether certain types of crime show seasonal patterns, regardless of temperature.
Argument 2.1: Increased rainfall has no correlation to the amount of burglaries#
Although one might expect rain to affect burglary rates, research from Beijing (Peng et al., 2011) found no significant link between precipitation and residential burglaries. This suggests that increased rainfall may not directly influence burglary incidents. Our analysis aims to explore whether this holds true in our data.
Show code cell source
# Titel en korte take-away boven de plot
display(Markdown("### Rainfall vs. Home Burglaries"))
display(Markdown("_There appears to be no clear correlation between monthly rainfall and burglary rates._"))
plt.figure(figsize=(10,6))
sns.regplot(
data=df,
x='RH', # gemiddelde neerslag in mm
y='1.1.1 Diefstal/inbraak woning',
scatter_kws={'s':50, 'alpha':0.6},
line_kws={'color':'red'}
)
plt.xlabel('Average Monthly Rainfall (mm)', fontsize=14)
plt.ylabel('Total Burglary Incidents per Month', fontsize=14)
plt.grid(True)
# Caption onderaan, gecentreerd en iets kleiner
caption = (
"Scatterplot shows monthly data points with average rainfall on the x-axis "
"and total burglary incidents on the y-axis. The red line represents the regression trend."
)
plt.gcf().text(0.5, -0.1, caption, ha='center', fontsize=10)
plt.tight_layout()
plt.show()
# Bereken correlatie en helling
correlation, p_value = stats.pearsonr(df['RH'], df['1.1.1 Diefstal/inbraak woning'])
slope, intercept, r_value, p_value_reg, std_err = stats.linregress(df['RH'], df['1.1.1 Diefstal/inbraak woning'])
Rainfall vs. Home Burglaries
There appears to be no clear correlation between monthly rainfall and burglary rates.
This scatterplot shows average monthly rainfall (x-axis) versus total burglary incidents per month (y-axis). The red regression line indicates the trend, but with a Pearson correlation of just 0.077, there is almost no linear relationship. This suggests that increased rainfall has little to no effect on burglary rates, confirming the study from Peng et al. and our argument.
Argument 2.2: Serious crimes are not weather-dependent#
As for more serious crime, generally speaking, there is no obvious reason why it should depend on seasonal weather. Murder, abuse and cybercrime should not be associated with seasonal patterns. Warm days may lead to more activity and opportunity to commit these crimes, while cold days in turn may enable more of a melancholic mental state that motivates them more. Cybercrime sounds like an indoor activity, creating the expectation of more cybercrime in the winter, which we will analyse now.
Show code cell source
# Map each month number to a season
season_map = {
1: 'Winter', 2: 'Winter', 12: 'Winter',
3: 'Spring', 4: 'Spring', 5: 'Spring',
6: 'Summer', 7: 'Summer', 8: 'Summer',
9: 'Autumn', 10: 'Autumn', 11: 'Autumn'
}
# Extract numeric month from 'year_month' and map to season
df['month'] = pd.to_datetime(df['year_month']).dt.month
df['Season'] = df['month'].map(season_map)
# Serious crime columns and their display names
display(Markdown("### Seasonal Distribution of Serious Crimes"))
display(Markdown("_Serious crimes like murder, abuse, and cybercrime show relatively steady distribution across seasons._"))
serious_crimes = {
'1.4.2 Moord, doodslag': 'Murder, manslaughter',
'1.4.5 Mishandeling': 'Abuse',
'3.7.4 Cybercrime': 'Cybercrime'
}
fig, axes = plt.subplots(1, 3, figsize=(24, 9)) # Nog groter
for ax, (col, label) in zip(axes, serious_crimes.items()):
season_totals = df.groupby('Season')[col].sum().reindex(['Winter', 'Spring', 'Summer', 'Autumn'])
wedges, texts, autotexts = ax.pie(
season_totals,
labels=season_totals.index,
autopct='%1.1f%%',
startangle=90,
colors=sns.color_palette("pastel")[0:4],
textprops={'fontsize': 18} # Grotere labels en percentages
)
ax.set_title(f'Seasonal Distribution of {label}', fontsize=22, fontweight='bold')
# Caption groter en iets lager
caption = (
"Each pie chart shows the proportion of incidents per season for three serious crimes. "
"Values are total counts summed over all years. "
"Colors represent Winter, Spring, Summer, and Autumn respectively."
)
fig.text(0.5, -0.09, caption, ha='center', fontsize=18)
plt.tight_layout(rect=[0, 0.12, 1, 0.95]) # Meer ruimte onderin voor caption
plt.show()
Seasonal Distribution of Serious Crimes
Serious crimes like murder, abuse, and cybercrime show relatively steady distribution across seasons.
These pie charts show the seasonal distribution of monthly incidents for murder, abuse, and cybercrime. If these crimes were season-dependent, large differences would be visible, especially between summer and winter. However, the distributions are fairly even across all seasons. Winter appears slightly lower due to February having fewer days. Cybercrime might occur a bit more in winter, but overall, no substantial seasonal pattern is visible. This chart supports the claim that bad weather has little influence on serious crimes.
Conclusion#
As shown earlier, certain crime types, like bike theft or substance-related incidents on boats, show notable correlations with weather. Warmer and brighter days can influence behavior in ways relevant to crime prediction. In contrast, serious crimes show little to no weather dependency. To highlight this, we compare how various crimes relate to monthly maximum temperature alongside ‘under influence on water’ incidents.
Show code cell source
import plotly.graph_objects as go
from IPython.display import display, Markdown
crime_columns = {
'Burglary (home)': '1.1.1 Diefstal/inbraak woning',
'Traffic Accidents': '1.3.1 Ongevallen (weg)',
'Under Influence (water)': '3.4.2 Onder invloed (water)',
'Murder, manslaughter': '1.4.2 Moord, doodslag',
'Shoplifting': '2.5.2 Winkeldiefstal',
'Pickpocketing': '1.2.4 Zakkenrollerij',
'Bicycle Theft': '1.2.3 Diefstal van brom-, snor-, fietsen'
}
def frange(start, stop, step):
while start <= stop:
yield round(start, 1)
start += step
def create_slider_plot(df):
temps = [round(t, 1) for t in list(frange(5.0, 26.5, 0.5))]
fig = go.Figure()
# Voeg alle frames toe, één per temperatuur
frames = []
for temp in temps:
lower, upper = temp - 0.5, temp + 0.5
filtered = df[(df['TX'] >= lower) & (df['TX'] < upper)]
y = [
(filtered[col].sum() / df[col].sum()) * 100 if df[col].sum() > 0 else 0
for col in crime_columns.values()
]
frames.append(go.Frame(
data=[go.Bar(x=list(crime_columns.keys()), y=y)],
name=f"{temp}"
))
# Voeg eerste data toe als initiele trace
fig.add_trace(frames[0].data[0])
# Zet layout, slider en frames
fig.update_layout(
yaxis=dict(range=[0, 25], title="Pct of Total Incidents"),
xaxis_title="Crime Type",
width=800,
height=600,
margin=dict(b=130), # Extra ruimte onderaan voor slider
updatemenus=[dict(
type="buttons",
showactive=False,
buttons=[dict(label="Play", method="animate",
args=[None, {
"frame": {"duration": 300, "redraw": True},
"fromcurrent": True,
"transition": {"duration": 0}
}])]
)],
sliders=[dict(
active=temps.index(5.0),
currentvalue={"prefix": "Temp: "},
pad={"t": 80}, # Verplaatst slider omlaag
steps=[dict(label=f"{t}°C", method="animate", args=[[str(t)], {
"frame": {"duration": 0},
"mode": "immediate"
}]) for t in temps]
)]
)
fig.frames = frames
return fig
# Titel en korte conclusie boven de interactieve plot
display(Markdown("### Crime Distribution Changes with Temperature"))
display(Markdown("_Different weather only encourages very specific types of crime, most are evenly distributed._"))
# Plot tonen
fig = create_slider_plot(df)
fig.show()
Crime Distribution Changes with Temperature
Different weather only encourages very specific types of crime, most are evenly distributed.
Only ‘under influence (water)’ clearly shows a relationship with temperature; other crime types fluctuate slightly but remain fairly evenly spread across all temperatures. Since the data wasn’t normalized, extreme cold or heat appears underrepresented: these conditions are rare, so related crimes are also rarer. This chart sums up our analysis: while some crimes may respond to weather changes like more heat meaning more bike theft, most serious crimes are largely unaffected by factors like temperature, visibility, and rainfall.
References#
Anderson, C. A. (2001). Heat and violence. Current directions in psychological science, 10 (1), 33–38 (https://doi.org/10.1111/1467-8721.00109).
Centraal Bureau voor de Statistiek. (2025). Maandcijfers geregistreerde criminaliteit Amsterdam [dataset] [Accessed on June 10th 2025], (https://opendata.cbs.nl/statline/#/CBS/nl/dataset/83648NED/table?fromstatweb).
Koninklijk Nederlands Meteorologisch Instituut. (2025). Daggegevens van het weer in Nederland [dataset] [Accessed on June 10th 2025], (https://www.knmi.nl/nederland-nu/klimatologie/daggegevens).
Peng, C., Shu, X., Hongyong, Y., & Dengsheng, L. (2011). Assessing temporal and weather influences on property crime in Beijing, China. Crime, Law and Social Change, 55(1), 1–13. (https://doi.org/10.1007/s10611-010-9264-3)